package com.robot.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.robot.bean.Employee;
import com.robot.bean.User;
import com.robot.dto.EmployeeMapper;
import com.robot.service.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by duqingxiang on 17/5/1.
 */
@RestController
@EnableAutoConfiguration
public class IndexController {


    @Autowired
    UserService userService;

    @RequestMapping(value="/",method = RequestMethod.GET)
    public String index(){

        List<User> userList = userService.findAll();





        return "Hello World ~~~";
    }

    @RequestMapping(value="/returnJSON",method = RequestMethod.POST)
    public String returnJSON(@RequestParam("name") String name){

        System.out.println("returnJSON  param : name:"+name);
        List<User> userList = userService.findAll();


        return JSON.toJSONString(userList.get(0));
    }
}
